package com.twq

import org.apache.spark.{SparkConf, SparkContext}

object WordCountLocal {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("WordCount")
    conf.setMaster("local")

    val sparkContext = new SparkContext(conf)

    val textFileRDD = sparkContext.textFile("src/main/resources/word.txt")

    val wordRDD = textFileRDD.flatMap(line => line.split(" "))

    val pairWordRDD = wordRDD.map(word => (word, 1))

    println("Hello , this is my debug point")

    val wordCountRDD = pairWordRDD.reduceByKey((a, b) => a + b)

    wordCountRDD.saveAsTextFile("src/main/resources/wordcount")
  }

}
